<template>
  <div class="product-list">
    <!-- @click="productListClick" -->
    <div class="product-list-header">
      <!-- <div class="header-icon"></div> -->
      <span class="header-title">{{title}}</span>
      <!-- <span class="iconfont" @click="goMore(title)">更多</span> -->
    </div>
  </div>
</template>

<script>
import { getChatCount } from "../../../api/memberChat";
import StoreProductList from "./StoreProductList";
import StoreProductBody from "./StoreProductBody";
import { mapState, mapActions } from "vuex";
import { getStoreInfo } from "../../../api/homestoredetail";

export default {
  name: "StoreList",
  data() {
    return {
      showDot: false,
      store: {
        store_id: this.$route.query.id ? this.$route.query.id : "",
      },
      rec_goods_list:"",
    };
  },
  props: ["title","storegcId"],
  components: {
    StoreProductList,
  },
  computed: {
    ...mapState({
      config: (state) => state.config.config,
      token: (state) => state.member.token,
      isOnline: (state) => state.member.isOnline,
    }),
  },
  created() {
  console.log(this.storegcId)
    getStoreInfo(this.store.store_id, this.token)
      .then((res) => {
        this.store = res.result.store_info;
        this.rec_goods_list = res.result.rec_goods_list;
        console.log(res)
        if (this.store.is_platform_store) {
          this.fetchConfig({}).then(
            (response) => {},
            (error) => {
              Toast(error.message);
            }
          );
        }
      })
      .catch(function (error) {});
    if (this.isOnline) {
      getChatCount().then((res) => {
        if (res.result) {
          this.showDot["chat"] = true;
        }
      });
    }
  },
  methods: {
    ...mapActions({
      fetchConfig: "fetchConfig",
    }),
    productListClick: function () {},
    goMore(titles){
      console.log(this.storegcId)
      // return
      console.log(titles)
      if(titles == "新品上架"){
        this.$router.push({name:"HomeStoreRecommendation",query:{id:this.store.store_id,vuale:"2",storegId:this.storegcId}});
      }else{
        console.log(1212121)
        this.$router.push({name:"HomeStoreRecommendation",query:{id:this.store.store_id,vuale:"1",storegId:this.storegcId}});
      }
    },
  },
};
</script>

<style lang="scss" scoped>
.advertisement{
  width: 100%;
}
.advertisement img{
  width: 100%;
  height: 4.92rem;
  margin-bottom: 0.6rem;
}
.iconfont{
  font-size: 0.7rem;
  color: #101010;
}
.product-list {
  background: #ffffff;
  // margin-top: 0.6rem;
  // margin-bottom: 0.5rem;
  .product-list-header {
    // display: flex;
    width: 17.5rem;
    height: 2rem;
    line-height: 2rem;
    padding: 0 0.25rem;
    margin-top: 0.5rem;
    margin: auto;
    // justify-content: space-between;
    text-align: center;
    // align-items: center;
    border-bottom: 1px solid #f5f5f5;
    .header-title {
      font-size: 0.7rem;
      color: #333;
    }
    .header-icon {
      width: 1rem;
      height: 1rem;
    }
  }
  .product-list-body {
    display: flex;
    flex-wrap: wrap;
  }
}
</style>
